package com.nobody.facepk.model;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.nobody.facepk.persist.VersionedPersistentSupport;
import com.nobody.facepk.service.ServiceRegistry;

@Entity
@Table(name="T_USER")
public class User extends VersionedPersistentSupport{
	private String name;
	private String realName;
	private int gender;
	private boolean single;
	private int charm;
	private String mobile;
	private String email;
	private Long friendId;
	private Long dataEntryId;
	

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRealName() {
		return this.realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public int getGender() {
		return this.gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}

	public boolean isSingle() {
		return this.single;
	}

	public void setSingle(boolean single) {
		this.single = single;
	}

	public int getCharm() {
		return this.charm;
	}

	public void setCharm(int charm) {
		this.charm = charm;
	}

	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public Long getFriendId() {
		return this.friendId;
	}
	public void setFriendId(Long friendId) {
		this.friendId = friendId;
	}
	public Long getDataEntryId() {
		return this.dataEntryId;
	}
	public void setDataEntryId(Long dataEntryId) {
		this.dataEntryId = dataEntryId;
	}

//	@Transient
//	public DataEntry getDataEntry() {
//		UserData data = ServiceRegistry.getGeneralDaoService().find(UserData.class, this.dataEntryId);
//		return JsonHelper.parse(DataEntry.class, data.getData());
//	}
	
	@Transient
	public UserData getUserData(UserDataType type) {
		return ServiceRegistry.getUserService().getUserData(this.getId(), type);
	}
	
//	@Transient
//	public void setUserData(UserData data) {
//		ServiceRegistry.getGeneralDaoService().save(data);
//	}
	
	@Transient
	public UserData getUserData(Long entryId) {
		return ServiceRegistry.getGeneralDaoService().find(UserData.class, entryId);
	}
	
//	@Transient
//	public <T> T getUserData(Long entryId, Class<T> type) {
//		UserData data = ServiceRegistry.getGeneralDaoService().find(UserData.class, entryId);
//		return JsonHelper.parse(type, data.getData());
//	}
}
